home *** CD-ROM | disk | FTP | other *** search
- /*[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]*/
- /*UDialog.p*/
- /*Copyright © 1988-1990 by Apple Computer Inc. All rights reserved.*/
- #ifndef __UDialog__
- #define __UDialog__ 0
- #endif
- #if ! __UDialog__
- #define __UDialog__ 1
-
- /* • Auto-Include the requirements for this unit's interface. */
- #ifndef __UMacApp__
- #include "UMacApp.h"
- #endif
- #ifndef __UTEView__
- #include "UTEView.h"
- #endif
-
- const short kPreferColor = true; /* argument to IIcon */
- const short kControlOn = true; /* argument to ICheckBox and IRadio */
-
- /* Constants for TDialogView.Dismiss */
- const short kFlash = true; /* Constants for TDialogView.Dismiss. */
- const short kDontFlash = false; /* Constants for TDialogView.Dismiss. */
-
- const unsigned char kFrame = (adnLineTop | adnLineLeft | adnLineBottom | adnLineRight);
- /* Constant
- defining that a view be completely framed. */
-
- const short kMaxTEWidth = 0x2B0; /* Maximum width for TEditText autoscroll */
-
- const short phInvalidValue = 300; /* Alert used when an invalid value is
- entered */
-
- const short kInvalidValueReasons = 300;
- /* String list used for invalid value alert */
- const short kErrorHandled = - 1;
- /* Don't post an alert, the user handled it */
- const short kValidValue = 0; /* Not looked up in the string list. */
- const short kInvalidValue = 1;
- const short kValueTooSmall = 2;
- const short kValueTooLarge = 3;
- const short kNonNumericCharacters = 4;
- const short kTooManyCharacters = 5;
- const short kNoOfDefaultReasons = 5;
-
- struct DialogViewTemplate {
- ResType defaultItem;
- ResType cancelItem;
- };
- typedef DialogViewTemplate *DialogViewTemplatePtr;
-
- class TDialogView : public TView {
- public: /* Mimics normal toolbox dialogs providing
- behavior for handling default buttons,
-
- param text, currently selected edit text
- and other behavior typically associated
- with dialogs. */
- ResType fDefaultItem; /* The identifier of the default item */
- ResType fCancelItem;
- /* The identifier of item that cancels dialog
- */
- TAssociation *fParamTxt; /* the list of TEntrys for replacement */
- struct TEditText *fCurrentEditText; /* Currently selected edit text item */
- struct TDialogTEView *fTEView; /* Used for editing in EditText views */
- Boolean fDismissed; /* Has the dialog been dismissed? */
- ResType fDismisser; /* ID of view that caused dismissal */
-
- virtual pascal void IDialogView(TDocument *itsDocument, TView *itsSuperView, VPoint *itsLocation
- , VPoint *itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, ResType
- itsDefItemID, ResType itsCancelItemID);
- /* Initialization method for TDialogView. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* For initializing a dialog view from a resource template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* For writing a dialog view out to a resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* For writing a dialog view to a resource, works in conjunction with tbe
- previous method. */
-
- virtual pascal void Free(void);
-
- /* Frees fParamTxt then removes the sub view fTEView before calling inherited Free. */
-
- virtual pascal Boolean CanDismiss(ResType dismissing);
- /* Used to check whether the dialog view can be dismissed or not by checking if the
- view is enabled, then check if the currently selected edit text is valid. */
-
- virtual pascal void CantDeselect(struct TEditText *theEditText, long reason);
-
- virtual pascal void Close(void);
- /* Called to close a dialog view. */
-
- virtual pascal void DismissDialog(ResType dismisser);
- /* The method responsible for actually dismissing a dialog. */
-
- virtual pascal TCommand *DoCommandKey(short ch, EventInfo *info);
- /* Called when a keyDown event is received and the command key is down. */
-
- virtual pascal TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
- /* This method handles all key presses other than a command key press, which is
- handled by the previous method. */
-
- virtual pascal void DoOpen(void);
-
- /* If when opening the dialog the current target is an edit text field of the dialog,
-
- then select it. */
-
- virtual pascal Boolean DeselectCurrentEditText(void);
- /* Deselects the current edit text, this is called when tabbing between edit text
- fields. */
-
- virtual pascal void DoSelectEditText(struct TEditText *theEditText, Boolean selectChars);
-
- /* Selects theEditText, is selectChars then all the characters are selected otherwise
- the insertion point is merely placed at the start of the field. */
-
- virtual pascal void EachEditText(pascal void (*DoToEditText)(struct TEditText *theEditText, void
- *DoToEditText_StaticLink), void *DoToEditText_StaticLink);
- /* Iterates over all the edit text items in the dialog calling DoToEditText for
- each item. */
-
- virtual pascal TView *GetDialogView(void);
- /* Returns a reference to the dialog view. */
-
- virtual pascal void Tab(Boolean tabBackward);
- /* Handles the tabbing between edit text fields. */
-
- virtual pascal void DoChoice(TView *origView, short itsChoice);
- /* If the default or cancel key are pressed then dismisses the dialog, otherwise
- passes the message along the chain. If the hit was an edit text item then deselects
- the item. Otherwise if the hit is on some other control and it dismisses the dialog
- then dismiss it. */
-
- virtual pascal struct TDialogTEView *MakeTEView(void);
- /* Creates the floating TEView used with edit text fields. */
-
- virtual pascal void Open(void);
- /* Called to open a dialog. */
-
- virtual pascal void ParamTxt(StringPtr keyStr, StringPtr valueStr);
- /* Used to create paramTxt items for the dialog. Builds an association with keyStr
- and valueStr. All instance of keyStr in the dialog will be replaced with valueStr
- when the dialog is displayed. */
-
- virtual pascal ResType PoseModally(void);
- /* Displays the dialog in a modal fashion waiting for a response, which is returned
- as the IDType of the button hit that causes the dialog to be dismissed. */
-
- virtual pascal void ReplaceText(StringPtr theText);
- /* If there are any param text items in the theText passed to this method then they
- are replaced with the appropriate values. */
-
- virtual pascal void SelectEditText(ResType itsIdentifier, Boolean selectChars);
-
- /* If itsIdentifier can be found then the field is selected, selectChars if true means
- that all the text will be selected as opposed to the insertion point merely being
- placed in the field. */
-
- virtual pascal void SurveyEditText(struct TEditText **first, struct TEditText **last, struct
- TEditText **next, struct TEditText **previous);
- /* Iterates over the edit text items in the view finding the First, Last, Next and
- Previous items. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- struct ButtonTemplate {
- Str255 itsLabel; /* Actually, variable length */
- };
- typedef ButtonTemplate *ButtonTemplatePtr;
-
- class TButton : public TCtlMgr {
- public:
- /* Mimics a typical toolbox button as used in
- a dialog. */
- virtual pascal void IButton(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize,
- SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, StringPtr itsLabel);
- /* Initializes the button setting the fDefChoice field to mButtonHit. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize the view from a resource template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Write this object out as a view resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Set up the type and signature of this object and call WRes. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- struct CheckBoxTemplate {
- Boolean isOn;
- Str255 itsLabel; /* Actually, variable length */
- };
- typedef CheckBoxTemplate *CheckBoxTemplatePtr;
-
- class TCheckBox : public TCtlMgr {
- public: /* Provides the functionality of a toolbox
- checkbox. */
- virtual pascal void ICheckBox(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize,
- SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, StringPtr itsLabel, Boolean
- isTurnedOn);
- /* Initialize the checkbox setting fDefChoice to mCheckBoxHit. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize the view from a resource template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Write this object out as a view resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Set up the type and signature of this object and call WRes. */
-
- virtual pascal void DoChoice(TView *origView, short itsChoice);
- /* If the hit is mCheckBoxHit then toggle the checkbox. */
-
- virtual pascal Boolean IsOn(void);
- /* Is the checkbox currently checked. */
-
- virtual pascal void SetState(Boolean state, Boolean redraw);
- /* Sets the state of the checkbox to state and if redraw is TRUE redraws it. */
-
- virtual pascal void Toggle(Boolean redraw);
- /* Toggles the state of the checkbox redraw it if redraw is TRUE. */
-
- virtual pascal void ToggleIf(Boolean matchState, Boolean redraw);
- /* Toggles the state of the checkbox if matchState is TRUE redrawing if redraw is
- TRUE. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- struct RadioTemplate {
- Boolean isOn;
- Str255 itsLabel; /* Actually, variable length */
- };
- typedef RadioTemplate *RadioTemplatePtr;
-
- class TRadio : public TCtlMgr {
- public: /* Provides the functionality of a toolbox
- radio button. */
- virtual pascal void IRadio(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize,
- SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, StringPtr itsLabel, Boolean
- isTurnedOn);
- /* Initalize the radio button procedurally. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize the view from a resource template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Write the object out as a view resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Set up the type and signature of this object and call WRes. */
-
- virtual pascal void DoChoice(TView *origView, short itsChoice);
- /* If the hit is mRadioHit then toggle the radio button. */
-
- virtual pascal Boolean IsOn(void);
- /* Is the radio button currently on. */
-
- virtual pascal void SetState(Boolean state, Boolean redraw);
- /* Sets the state of the radio button to state, redrawing if redraw is TRUE. */
-
- virtual pascal void Toggle(Boolean redraw);
- /* Toggles the state of the radio button, redrawing if redraw is TRUE. */
-
- virtual pascal void ToggleIf(Boolean matchState, Boolean redraw);
- /* Only toggles the state of the radio button if matchState is TRUE, redrawing if
- redraw is TRUE. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- struct ClusterTemplate {
- Str255 itsLabel; /* Actually, variable length */
- };
- typedef ClusterTemplate *ClusterTemplatePtr;
-
- class TCluster : public TControl {
- public:
- /* Provides a mechanism whereby radio buttons
- can be grouped in clusters, such that when
- one of the buttons is selected the others
- are all deselected. Also can be utilized
- for providing labelled adornments around
- groups of dialog items. */
- short fRsrcID; /* resource ID of the cluster's label */
- short fIndex; /* currently selected item */
- StringHandle fDataHandle; /* the cluster's label */
-
- virtual pascal void ICluster(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize,
- SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, short itsRsrcID, short itsIndex);
- /* Initialize the cluster procedurally. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize the view template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Write the object out as a view resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Set up the type and signature of this object and call WRes. */
-
- virtual pascal void Free(void);
- /* Release the label and call inherited free. */
-
- virtual pascal void Draw(Rect *area);
- /* Frame the cluster if there is a label, then draw the label. */
-
- virtual pascal void DoChoice(TView *origView, short itsChoice);
- /* Responsible for reset the radio buttons so that the last selected one is the only
- one selected. */
-
- virtual pascal void GetLabel(StringPtr theLabel);
- /* Returns in theLable the text in the clusters label. */
-
- virtual pascal void ReleaseLabel(void);
-
- /* Releases fDataHandle which is a string handle containing the text for the label. */
-
- virtual pascal ResType ReportCurrent(void);
- /* Returns the IDType of the currently selected item. */
-
- virtual pascal void SetLabel(StringPtr theLabel, Boolean redraw);
- /* Sets the clusters label to be theLabel, redrawing if redraw is TRUE. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
- };
-
- struct IconTemplate {
- Boolean preferColor;
- short rsrcID;
- };
- typedef IconTemplate *IconTemplatePtr;
-
- class TIcon : public TControl {
- public: /* Provides an icon that can behave as a
- button. */
- Boolean fPreferColor;
- short fRsrcID;
- Handle fDataHandle;
-
- virtual pascal void IIcon(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize,
- SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, short itsRsrcID, Boolean preferColor)
- ;
- /* Initialize the view template. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize the view template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Write the object out as a view resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Set up the type and signature of this object and call WRes. */
-
- virtual pascal void Free(void);
- /* Release the icon then call inherited Free. */
-
- virtual pascal void Draw(Rect *area);
- /* Resonsible for drawing the icon and any required adornments. */
-
- virtual pascal void ReleaseIcon(void);
- /* Releases the handle to the icon. */
-
- virtual pascal void SetIcon(Handle theIcon, Boolean redraw);
- /* Sets fDataHandle to theIcon, redrawing if redraw is TRUE. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
- };
-
- struct PatternTemplate {
- Boolean preferColor;
- short rsrcID;
- };
- typedef PatternTemplate *PatternTemplatePtr;
-
- class TPattern : public TControl {
- public: /* Provides an object that can display a
- pattern and can also behave as a button if
- required. */
- Boolean fPreferColor;
- short fRsrcID;
- Handle fDataHandle;
-
- virtual pascal void IPattern(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize,
- SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, short itsRsrcID, Boolean preferColor)
- ;
- /* Initialize the pattern procedurally. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize the view template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Write the object out as a view resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Set up the type and signature of this object and call WRes. */
-
- virtual pascal void Free(void);
- /* Release the pattern then call inherited Free. */
-
- virtual pascal void Draw(Rect *area);
- /* Responsible for drawing the pattern and any required adornments. */
-
- virtual pascal void ReleasePattern(void);
- /* Releases the pattern by disposing fDataHandle. */
-
- virtual pascal void SetPattern(Handle thePattern, Boolean redraw);
- /* Sets fDataHandle to thePattern, redrawing if redraw is TRUE. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
- };
-
- struct PictureTemplate {
- short rsrcID;
- };
- typedef PictureTemplate *PictureTemplatePtr;
-
- class TPicture : public TControl {
- public:
- /* Provides an object that can display a PICT
- and if required behave like a button. */
- short fRsrcID;
- PicHandle fDataHandle;
-
- virtual pascal void IPicture(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize,
- SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, short itsRsrcID);
- /* Initialize the picture procedurally. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize the view from a resource template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Write the object out as a view resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Set up the type and signature of this object and call WRes. */
-
- virtual pascal void Free(void);
- /* Release the picture then call inherited Free. */
-
- virtual pascal void Draw(Rect *area);
- /* Responsible for drawing the PICT and any required adornments. */
-
- virtual pascal void ReleasePicture(void);
- /* Releases the PICT by disposing of fDataHandle. */
-
- virtual pascal void SetPicture(PicHandle thePicture, Boolean redraw);
- /* Sets fDataHandle to thePicture, redrawing if redraw is TRUE. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
- };
-
- struct PopupTemplate {
- short rsrcID;
- short currentItem;
- short itemOffset;
- };
- typedef PopupTemplate *PopupTemplatePtr;
-
- class TPopup : public TControl {
- public: /* Provides a popup menu that can have a
- label associated with it. */
- short fRsrcID;
- short fMenuID;
- MenuHandle fMenuHandle;
- short fCurrentItem;
- short fItemOffset;
-
- virtual pascal void IPopup(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize,
- SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, short itsRsrcID, short itsCurrentItem
- , short itsItemOffset);
- /* Initialize the popup procedurally. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize the view template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Write the object out as a view resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Set up the type and signature of this object and call WRes. */
-
- virtual pascal void Free(void);
- /* Release the popup then calls inherited Free. */
-
- virtual pascal void AdjustBotRight(void);
- /* Adjusts the width and height of the popup menu. */
-
- virtual pascal void CalcLabelRect(Rect *theRect);
- /* Calculates the size of the rect for the label. */
-
- virtual pascal void CalcMenuRect(Rect *theRect);
- /* Calculates the size of the rect for the menu. */
-
- virtual pascal TCommand *DoMouseCommand(Point *theMouse, EventInfo *info, Point *hysteresis);
- /* Responds to a mouse down on the popup menu by highlighting the label and then
- calling PopUpMenuSelect to handle the display of the menu and then sets the current
- item to the one selected. */
-
- virtual pascal void Draw(Rect *area);
- /* Calls DrawPopupBox and DrawLabel to handle the drawing of the popup box and the
- label. */
-
- virtual pascal void DrawLabel(Rect *area);
- /* Responsible for drawing the label. */
-
- virtual pascal void DrawPopupBox(Rect *area);
- /* Does the actual drawing of the popup box. */
-
- virtual pascal short GetCurrentItem(void);
- /* Returns the currently check marked item. */
-
- virtual pascal void GetItemText(short item, StringPtr theText);
- /* Gets the text for the currently selected item. */
-
- virtual pascal void ReleasePopup(void);
- /* Releases the popup by disposing of the menu handle. */
-
- virtual pascal void SetCurrentItem(short item, Boolean redraw);
- /* Sets the currently selected item, redrawing is required. */
-
- virtual pascal void SetPopup(MenuHandle theMenu, short theRsrcID, short currentItem, Boolean
- redraw);
- /* Sets the fields of the popup to contain theMenu, with currentItem selected,
-
- redrawing if required. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
- };
-
- struct StaticTextTemplate {
- short just;
- Str255 data; /* Actually, variable length */
- };
- typedef StaticTextTemplate *StaticTextTemplatePtr;
-
- class TStaticText : public TControl {
- public: /* Provides an object that represents a
- toolbox static text item. */
- short fRsrcID; /* ID of the string list that the string is
- in. */
- short fIndex;
- /* Index number for the string from the above
- list. */
- StringHandle fDataHandle; /* A handle to the actual string. */
- short fJust;
- /* Jusitification of the text in the field. */
- Boolean fAutoWrap;
- /* TRUE to word wrap lines at the view boundary
- otherwise lines wrap at Carriage return. */
-
- virtual pascal void IStaticText(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize,
- SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, short itsRsrcID, short itsIndex);
- /* Initialize the static text field procedurally. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize the view template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Write the object out as a view resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Set up the type and signature of this object and call WRes. */
-
- virtual pascal void Free(void);
- /* Releases the text and then calls inherited Free. */
-
- virtual pascal void DoSubstitution(StringPtr theText);
- /* Calls ReplaceText so that any paramTxt items can be handled if needed. */
-
- virtual pascal void Draw(Rect *area);
- /* Draws the text by calling ImageText. */
-
- virtual pascal void GetText(StringPtr theText);
-
- /* If fDataHandle not NIL then returns the text, otherwise returns the null string. */
-
- virtual pascal void ImageText(Ptr text, long length, Rect *box, short just);
- /* Draws the text using the toolbox routine TextBox. */
-
- virtual pascal void ChangeWrap(Boolean newAutoWrap, Boolean redraw);
- /* Changes auto-wrapping behavior, redrawing if requested */
-
- virtual pascal void ReleaseText(void);
- /* Releases the text by disposing of fDataHandle. */
-
- virtual pascal void SetJustification(short theJust, Boolean redraw);
- /* Sets the justification of the text to theJust, redrawing if required. */
-
- virtual pascal void SetText(StringPtr theText, Boolean redraw);
- /* Sets the text to theText, redrawing if required. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
- };
-
- struct EditTextTemplate {
- short maxChars;
- ControlCharSet controlChars;
- };
- typedef EditTextTemplate *EditTextTemplatePtr;
-
- class TEditText : public TStaticText {
- public: /* Implements an edit text field. */
- short fMaxChars;
- struct TDialogTEView *fTEView;
- ControlCharSet fControlChars; /* Control chars accepted in text */
-
- virtual pascal void IEditText(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize, short
- itsMaxChars);
- /* Initialize the edit text item procedurally. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize the view from a resource template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Write the object out as a view resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Set up the type and signature of this object and call WRes. */
-
- virtual pascal void Free(void);
-
- /* Un-installs the floating TEView, sets fTEView to NIL then calls inherited Free. */
-
- virtual pascal Boolean HandleMouseDown(VPoint *theMouse, EventInfo *info, Point *hysteresis,
- TCommand **theCommand);
- /* Gets the floating TE installed if necessary and forwards the call to it. */
-
- virtual pascal void DoSubstitution(StringPtr theText);
- /* Default is to do nothing. */
-
- virtual pascal void Draw(Rect *area);
-
- /* If TEView not NIL then calls TEView.Draw before performing any required adornments,
-
- else calls inherited Draw. */
-
- virtual pascal void GetText(StringPtr theText);
- /* If TEView not NIL then returns the extracted text, otherwise calls inherited
- GetText. */
-
- virtual pascal void ImageText(Ptr text, long length, Rect *box, short just);
- /* Sets up the text to the parameters passed. Text is drawn in a'box' , the text is
- 'length' long. */
-
- virtual pascal void InstallSelection(Boolean wasActive, Boolean beActive);
- /* If TEView not NIL then calls TEView.InstallSelection. */
-
- virtual pascal void RestartEdit(StringPtr restartText);
- /* This method resets the text of the view, as well as selecting the text. We go to
- some extra trouble to ensure that this method doesn't do any drawing, defering to
- window update time. The reasoning is that this method usually gets called right
- after displaying an alert. The alert may have obscured this view, thus including it
- in the window's update region. If we drew in this method we would get flashing as
- this view would get redraw at update time. Unfortunately TextEdit isn't very
- cooperative so we set the clipping to an empty rect to ensure that TEActivate's
- drawing isn't seen. */
-
- virtual pascal void ChangeWrap(Boolean newAutoWrap, Boolean redraw);
- /* Changes auto-wrapping behavior, redrawing if requested. Forwards into
- the floating TE if necessary. */
-
- virtual pascal void SetJustification(short theJust, Boolean redraw);
- /* Sets the justification of the text to theJust, redrawing is required. */
-
- virtual pascal void SetSelection(short selStart, short selEnd, Boolean redraw);
- /* Sets the selection in the field starting at selStart and ending at selEnd,
-
- redrawing if required. */
-
- virtual pascal void SetText(StringPtr theText, Boolean redraw);
- /* Sets the displayed text to theText, redrawing if required. */
-
- virtual pascal void StartEdit(Boolean selectChars, struct TDialogTEView *theTEView);
- /* Install the selection, revealing the selection if required. */
-
- virtual pascal void StopEdit(void);
- /* Extracts the string from the TEView, then clears out the TEView before calling
- SELF.SetText. */
-
- virtual pascal long Validate(void);
- /* By default just returns TRUE. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
- };
-
- struct NumberTextTemplate {
- long value;
- long minimum;
- long maximum;
- };
- typedef NumberTextTemplate *NumberTextTemplatePtr;
-
- class TNumberText : public TEditText {
- public:
- /* This subclass of TEditText that allows the
- handling of integer numbers. Range
- checking will be performed on the numbers
- entered to see if they are in the range
- fMinimum to fMaximum. */
- long fMinimum;
- long fMaximum;
-
- virtual pascal void INumberText(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize, long
- itsValue, long itsMinimum, long itsMaximum);
- /* Initialize the number text item procedurally. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize the view template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Write the object out as a view resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* Set up the type and signature of this object and call WRes. */
-
- virtual pascal long GetValue(void);
- /* Returns the current value by getting the string and converting it to a number. */
-
- virtual pascal void SetValue(long newValue, Boolean redraw);
- /* Sets the current value by converting the number to a string and then calling
- SetText. */
-
- virtual pascal long Validate(void);
-
- /* Does a range check on the number and if it is out of range returns the appropriate
- error code. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
- };
-
- class TDialogTEView : public TTEView {
- public: /* Provides a floating TEView that is placed
- over edit & number text fields when
- entering text. */
- TEditText *fEditText; /* The edit text field to which the floating
- TEView is currently tied. */
-
- TScroller *fScroller;
- /* The scroller that I am in for mouseability. */
-
- virtual pascal void IDialogTEView(TDocument *itsDocument, TView *itsSuperView, VPoint *
- itsLocation, VPoint *itsSize, SizeDeterminer itsHDeterminer, SizeDeterminer itsVDeterminer,
- Rect *itsInset, TextStyle *itsTextStyle, short itsJustification, Boolean itsStyleType, Boolean
- itsAutoWrap);
- /* For Initialization of procedurally created TEView. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize a TTEView via a 'view' resource. */
-
- virtual pascal void Free(void);
- /* Free associated components and then free self. */
-
- virtual pascal void InstallEditText(TEditText *theEditText, Boolean selectChars);
- /* Installs the EditText adding SELF as a subview to EditText, then gets the text
- from the EditText item and installs it in SELF. */
-
- virtual pascal void ComputeSize(VPoint *newSize);
- /* accounts for case in which horizontal determiner is sizeVariable should be added
- to TTEView !!! */
-
- virtual pascal void InstallSelection(Boolean wasActive, Boolean beActive);
-
- /* If deactivating then invalidate rect before calling inherited InstallSelection. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- virtual pascal struct TScroller *MakeScroller(void);
- /* Creates the floating scroller that goes with the TE. . */
-
-
- };
-
- extern pascal void InitUDialog(void);
- /* This routine must be called if UDialog is used so that all the necessary initializati
- on can
- be performed. Sets the global flag 'gUDialogInitialized' after the initalization is
- performed. */
-
- extern pascal void GetMenuColors(Rect *popupRect, short menuID, short itemNum, RGBColor *fColor,
- RGBColor *bColor);
- /* */
-
- #endif
-
-